<div class="container-fluid" style="margin: 0px 15px 0px 15px;">
<ol class="breadcrumb">
  <li><a href="<?php echo base_url('/index.php/inicio');?>">Início</a></li>
  <li><a href="<?php echo base_url('index.php/usuarios/novo');?>">Usuário</a></li>
  <li class="active">Consulta</li>
</ol>
	<fieldset>
		<legend>Consulta Usuário</legend>
		<a data-toggle="modal" href="<?php echo base_url('index.php/usuarios/novo');?>" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-plus"></span>Adicionar Usuário</a>
		<br/>
		<br/>
		<table id="example" class="display responsive nowrap" cellspacing="0" width="100%">
			<thead>
				<tr>
					
					<th>Nome</th>
					<th>Permissão</th>
					<th>Último Acesso</th>
					<th>Status</th>
					<th></th>
				</tr>
			</thead>
			<tbody>
			<?php
				
				foreach($usuario as $u){
					echo '<tr>';
					echo '<td>'.$u->nome_completo.'</td>';
					echo '<td>'.$u->nome_permissao.'</td>';
					echo '<td>'.$u->dt_ultimo_acesso.'</td>';
					//------------------------------------------------------------------------------------------------------
					$class = '';
					$msg = '';
					if($u->status == '0'){
						$class = 'class="btn btn-danger btn-xs"';
						$msg = 'INATIVO';
					}else{
						$class = 'class="btn btn-success btn-xs"';
						$msg = 'ATIVO';
					}
					$men = '';
					switch($u->tipo){
						case 'F': $men = "FÉRIAS";break;
						case 'A': $men = "AFASTAMENTO";break;
						case 'L': $men = "LICENÇA";break;
					}
					$ausente = '';
					if(!empty($men)){
						$ausente = '<a style="padding: 1px 1px 1px 1px;" href="#" class="btn btn-warning btn-xs" title="'.$u->dt_inicio.' a '.$u->dt_fim.'">'.$men.'</a>';
					}
					//------------------------------------------------------------------------------------------------------
					echo '<td><a style="padding: 1px 1px 1px 1px;"  href="#" '.$class.'>'.$msg.'</a> '.$ausente.'</td>';
					echo '<td>';
					
					echo '<a style="padding: 1px 1px 1px 1px;" href="'.base_url("index.php/usuarios/info/$u->id").'" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-plus"></span>Detalhes</a>';
					if(empty($men) && $u->status == '1'){
						echo ' <a style="padding: 1px 1px 1px 1px;" href="'.base_url("index.php/ausentes/novo/$u->id").'" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-plus"></span>Adicionar Férias</a>';
					}
					echo'</td>';
				
					echo '</tr>';
		
				}
			?>
			</tbody>
		</table>
	</fieldset>
	
	</div>
		<script type="text/javascript" charset="utf-8">

			$(document).ready(function() {
				$('#example').DataTable({
					"language": {
						"url": "<?php echo base_url('includes/js/Portuguese-Brasil.json'); ?>"
					},
					 "pagingType": "simple"
				});
			});
		</script>
	</body>
</html>